import pandas as pd
pd.set_option('dis_play.unicode.east_asian_width',True)
df=pd.read_excel('超市运营数据.xlsx')
data=[]
for i in range(df['折扣'].size):
    if df['折扣'][i] == 0:
        data.append(1)
    else:
        data.append(df['折扣'][i])
df['总额'] = df['价格'] * df['数量'] * data
df1=df.groupby('销售经理'.agg({'总额':'sum'}))
print('排序:\n',df1)
df1['排名']=df1.rank(method='first',ascending=False)
print('排序:\n',df1)
df1.sort_values(by='排名',ascending=True,inplace=True)
print('销售经理按总额降序排名以及按排名升序排序:\n',df1)
df2=df.groupby('客户类型'.agg({'总额':'sum'}))
print('排序:\n',df1)
df2['排名']=df1.rank(method='first',ascending=False)
print('排序:\n',df1)
df2.sort_values(by='排名',ascending=True,inplace=True)
print('客户类型按总额降序排名以及按排名升序排序:\n',df1)